/**
 * 将URL图片变成Base64
 * @param imgUrl
 */
export function convertImgToBase64(url, ext) {
	let response = null
	let canvas = document.createElement('canvas')   //创建canvas DOM元素
	let ctx = canvas.getContext('2d')
	let img = new Image
	img.crossOrigin = 'Anonymous'
	img.src = url
	img.onload = function () {
		canvas.width = img.width //指定画板的宽度，自定义
		canvas.height = img.height //指定画板的高度,自定义
		ctx.drawImage(img, 0, 0, img.width, img.height) //参数可自定义
		let dataURL = canvas.toDataURL('image/' + ext)
		response = dataURL
		canvas = null
	}
	return response
}

